package cc.eddic.pratice.programmingparadigms.emp03objlist.impl;

import cc.eddic.pratice.programmingparadigms.Result;
import cc.eddic.pratice.programmingparadigms.ResultComparator;
import cc.eddic.pratice.programmingparadigms.ResultPredicate;
import cc.eddic.pratice.programmingparadigms.emp02list.ResultList;
import cc.eddic.pratice.programmingparadigms.emp03objlist.ObjectList;



public class ResultListLhImpl extends ObjectList implements ResultList {
    public ResultListLhImpl(){
        super();
    }
    public ResultListLhImpl(int capacity){
        super(capacity);
    }

    @Override
    public Result findByGender(String gender) {
        return findByKey(gender);
    }
    @Override
    public Result findByDepartment(String department) {
        return findByKey(department);
    }
    @Override
    public Result findByJobTitle(String jobTitle) {
        return findByKey(jobTitle);
    }

    @Override
    public void add(Result result) {
        super.add(result);
    }

    @Override
    public Result get(int index) {
        return (Result) super.get(index);
    }

    @Override
    public Result find(ResultPredicate predicate) {
        return (Result) super.find(obj -> predicate.test((Result) obj));
    }

    @Override
    public void sort(ResultComparator comparator) {
        super.sort((o1, o2) -> comparator.compare((Result) o1, (Result) o2));
    }

    @Override
    public Result[] toArray() {
        Result[] r = new Result[size()];
        for (int i = 0; i < size(); i++) {
            r[i] = get(i);
        }
        return r;
    }


}
